?><?
class cls_attribute extends cls_entity{
  var $class_id=0;
  var $alias="";
  var $type="";
  var $class=null;
  var $description="";


  function cls_attribute(&$array){
    $this->class_id   =$array["class_id"];
    $this->id         =$array["attribute_id"];
    $this->name       =$array["attribute_name"];
    $this->type       =$array["attribute_type"];
    $this->alias      =$array["attribute_alias"];
    $this->class      =$array["attribute_class"];
    $this->description=$array["attribute_description"];
    $this->system     =$array["attribute_system"];
    $this->order      =$array["attribute_order"];
  }

	function entity(){return 'attribute';}

  function draw_as_edit($obj,$value,$form){   
    $fname=$this->name;
    $ftitle=$this->description?$this->description:$fname;
    $this->form->input($fname,$value,$ftitle,$this->alias);
  }

  function asText($val){
    if($this->alias!="relation"){
      return $val;
    }else{
      $result="";
      foreach($val as $obj){
        $result.=$obj->id().",";
      }
      return $result;
    }
  }

  function asXML(){
    return "<attribute id=\"$this->id\" name=\"$this->name\" alias=\"$this->alias\" class_id=\"$this->class_id\" description=\"$this->description\"/>";

  }
}
